#coding:utf-8
import time
import sys
import pyautogui as pg
import pyperclip as pc
 
 
class SendMsg(object):
 
    def __init__(self):
		# 发送对象的微信昵称
        #self.name = 'kanen'
		# 发送消息内容
        #self.msg = '大家好，我是微信小助手，这是一条自动发送的消息，请勿回复。
		
		# 发送对象的微信昵称
        self.name = sys.argv[1]
        # 发送消息内容
        self.msg = sys.argv[2]
 
    def send_msg(self):
        # 操作间隔为1秒
        pg.PAUSE = 1
		# 调出微信
        pg.hotkey('ctrl', 'alt', 'w')
        pg.hotkey('ctrl', 'f')
 
        # 找到好友
        pc.copy(self.name)
        pg.hotkey('ctrl', 'v')
        pg.press('enter')
 
        # 发送消息
        pc.copy(self.msg)
        pg.hotkey('ctrl', 'v')
		# 微信发消息快捷键
		#pg.press('enter')
        pg.hotkey('ctrl', 'enter')
 
        # 隐藏微信
        time.sleep(1)
        pg.hotkey('ctrl', 'alt', 'w')
 
 
if __name__ == '__main__':
    s = SendMsg()
    s.send_msg()